local sk__zhuizun = fk.CreateSkill {

  name = "sk__zhuizun",

  tags = { Skill.Limited, },

}



sk__zhuizun:addEffect(fk.EnterDying, {
  name = "sk__zhuizun",
  anim_type = "defensive",
  frequency = Skill.Limited,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__zhuizun.name) and player.dying and player:usedSkillTimes(sk__zhuizun.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover({
      who = player,
      num = 1 - player.hp,
      recoverBy = player,
      skillName = sk__zhuizun.name,
    })
    room:doIndicate(player.id, table.map(room:getOtherPlayers(player), Util.IdMapper))
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if player.dead then return end
      if not p.dead and not p:isKongcheng() then
        local card = room:askForCard(p, 1, 1, false, sk__zhuizun.name, false, ".", "#sk__zhuizun-give:"..player.id)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonGive, sk__zhuizun.name, nil, false, p)
      end
    end
    if not player.dead then
      player:gainAnExtraTurn(true, sk__zhuizun.name)
    end
  end,
})

return sk__zhuizun